#ifndef SHOWDATAFORGRAPH_H
#define SHOWDATAFORGRAPH_H

#include <QWidget>
#include <QtCharts>
#include <QCloseEvent>
#include <QVector>

QT_CHARTS_USE_NAMESPACE
namespace Ui {
class showDataForGraph;
}

class showDataForGraph : public QWidget
{
    Q_OBJECT

public:
    explicit showDataForGraph(QWidget *parent = nullptr);
    ~showDataForGraph();

private:
    Ui::showDataForGraph *ui;
    void InitSeries(const QStringList &str);
    void DataReceive(int _value, int index);

    int maxSize = 1000; // 仅存储最新的31个数据
    int maxX = maxSize;
    int maxY = 10;
    int minY = 0;
    bool initSeries = false;
    int serialTotal = 0;
    int timeId;

    QVector<QSplineSeries *> splineSeries;
    QVector<QVector<QPointF>> data;
    QChart *qchart;
    QValueAxis *axisX,*axisY;
public slots:
    void ReceiveShowData(const QString &str);
signals:
    void MeWillClose();
protected:
    void closeEvent(QCloseEvent *event) override;
    void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
};

#endif // SHOWDATAFORGRAPH_H
